﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DirectX;
using System.IO;
using BurningSphere.Simulator.Properties;
using Microsoft.DirectX.Direct3D;
using BurningSphere.Simulator.Controls;

namespace BurningSphere.Simulator
{
	/// <summary>
	/// Base shape class
	/// A shape is a series of points
	/// </summary>
	public class Shape
	{
		protected List<Vector2> points = new List<Vector2>();

		public Shape()
		{
		}

		public ShapeProjection Projection
		{
			get
			{
				return new ShapeProjection(this);
			}
		}

		public Shape(List<Vector2> points)
		{
			this.points = points;
		}

		public virtual void Load(string file)
		{
			string[] items = File.ReadAllLines(file);
			points = new List<Vector2>(items.Length);
			foreach (string item in items)
			{
				if (item.Trim().Length == 0)
				{
					continue;
				}
				string[] parts = item.Split(',');
				points.Add(new Vector2(Single.Parse(parts[0].Trim()), Single.Parse(parts[1].Trim())));
			}
		}

		public List<Vector2> Points
		{
			get
			{
				return points;
			}
		}
	}
}
